** Import "Brown-Thesis-Data" excel Sheet. 

** tell stata that we are working with panel data with "year" as the time variable and "conflict_id" as the group variable
xtset conflict_id year


** H1 regressions **

** any_action H1 (excluding nonstate_only)
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H1 and controls as the IVs
xtlogit any_action reg_total sharedigo_total_ext year gdppc_ln_ext p5_member reg_eap reg_mna reg_sca reg_eur reg_csa if nonstate_only==0
eststo H1a

** ga_res H1 (excluding nonstate_only)
** run a fixed effects logistic regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H1 and controls as the IVs
xtreg ga_res reg_total sharedigo_total_ext year gdppc_ln_ext p5_member reg_eap reg_mna reg_sca reg_eur reg_csa if nonstate_only==0
eststo H1b

** any_sc_action H1 (excluding nonstate_only)
** run a fixed effects logistic regression using "any_sc_action" as the DV (use logistic regression becuase "any_sc_action" is a binary variable) and the measurements for H1 and controls as the IVs
xtlogit any_sc_action reg_total sharedigo_total_ext year gdppc_ln_ext p5_member reg_eap reg_mna reg_sca reg_eur reg_csa if nonstate_only==0
eststo H1c

** sc_res_sancemb H1 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H1 and controls as the IVs
xtreg sc_res_sancemb reg_total sharedigo_total_ext year gdppc_ln_ext p5_member reg_eap reg_mna reg_sca reg_eur reg_csa if nonstate_only==0
eststo H1d

** sc_res_total H1 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H1 and controls as the IVs
xtreg sc_res_total reg_total sharedigo_total_ext year gdppc_ln_ext p5_member reg_eap reg_mna reg_sca reg_eur reg_csa if nonstate_only==0
eststo H1e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH1.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress



** H2 regressions **

** any_action H2 (excluding nonstate_only)
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H2 and controls as the IVs
xtlogit any_action milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0
eststo H2a 

** ga_res H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg ga_res milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0
eststo H2b

** sc_res_sancemb H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg sc_res_sancemb milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0
eststo H2c

** sc_res_total H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg sc_res_total milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0
eststo H2d

** pk_presence H2 (excluding nonstate_only)
** run a fixed effects logistic regression using "pk_presence" as the DV (use logistic regression becuase "pk_presence" is a binary variable) and the measurements for H2 and controls as the IVs
xtlogit pk_presence milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0
eststo H2e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH2.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress


** H3 regressions (lagged) **

** any_action H3 (lagged)
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H3 and controls as the IVs
xtlogit any_action L1.media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3a

** ga_res H3 (lagged)
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg ga_res L1.media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln
eststo H3b

** sc_res_humaid H3 (lagged)
** run a fixed effects OLS regression using "sc_res_humaid" as the DV (use OLS regression becuase "sc_res_humaid" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_humaid L1.media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3c

** sc_res_sancemb H3 (lagged)
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_sancemb L1.media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3d

** sc_res_total H3 (lagged)
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_total L1.media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln
eststo H3e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH3.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress


** H4 regression **

** any_action H4
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H4 and controls as the IVs
xtlogit any_action tradeshare_ln_ext refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln 
eststo H4a

** ga_res H4
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H4 and controls as the IVs
xtreg ga_res tradeshare_ln_ext refugees_ln_ext  battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H4b

** sc_res_humaid H4
** run a fixed effects OLS regression using "sc_res_humaid" as the DV (use OLS regression becuase "sc_res_humaid" is a continuous variable) and the measurements for H4 and controls as the IVs
xtreg sc_res_humaid tradeshare_ln_ext refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H4c

** sc_res_sancemb H4
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H4&5 and controls as the IVs
xtreg sc_res_sancemb tradeshare_ln_ext refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H4d

** sc_res_total H4
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H4 and controls as the IVs
xtreg sc_res_total tradeshare_ln_ext refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H4e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH4.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress



** H5 regression **

** any_action H5
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H5 and controls as the IVs
xtlogit any_action refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln 
eststo H5a

** ga_res H5
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H5 and controls as the IVs
xtreg ga_res refugees_ln_ext  battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H5b

** sc_res_sancemb H5
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H5 and controls as the IVs
xtreg sc_res_sancemb refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H5c

** sc_res_total H5
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H5 and controls as the IVs
xtreg sc_res_total refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln
eststo H5d

** pk_presence H5
** run a fixed effects logistic regression using "pk_presence" as the DV (use logistic regression becuase "pk_presence" is a binary variable) and the measurements for H45 and controls as the IVs
xtlogit pk_presence refugees_ln_ext battledeaths_ln multiple_mk duration year gdppc_ln_ext population_ln 
eststo H5e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH5.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress


** APPENDIX REGRESSIONS **

** H2 regressions without Iraq **

** generate variable excluding Iraq: "excl_iraq"
gen excl_iraq = 1
replace excl_iraq = 0 if cow_code==645

** any_action H2 (excluding nonstate_only)
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H2 and controls as the IVs
xtlogit any_action milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0 & excl_iraq==1
eststo H2a 

** ga_res H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg ga_res milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0 & excl_iraq==1
eststo H2b

** sc_res_sancemb H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg sc_res_sancemb milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0 & excl_iraq==1
eststo H2c

** sc_res_total H2 (excluding nonstate_only)
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H2 and controls as the IVs
xtreg sc_res_total milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0 & excl_iraq==1
eststo H2d

** pk_presence H2 (excluding nonstate_only)
** run a fixed effects logistic regression using "pk_presence" as the DV (use logistic regression becuase "pk_presence" is a binary variable) and the measurements for H2 and controls as the IVs
xtlogit pk_presence milpersonnel_ln_ext gdppc_ln_ext year population_ln if nonstate_only==0 & excl_iraq==1
eststo H2e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH2noiraq.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress


** H3 regressions (not lagged) **

** any_action H3 (not lagged) 
** run a fixed effects logistic regression using "any_action" as the DV (use logistic regression becuase "any_action" is a binary variable) and the measurements for H3 and controls as the IVs
xtlogit any_action media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3a

** unga_res H3 (not lagged)
** run a fixed effects OLS regression using "ga_res" as the DV (use OLS regression becuase "ga_res" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg ga_res media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln
eststo H3b

** sc_res_humaid H3 (not lagged)
** run a fixed effects OLS regression using "sc_res_humaid" as the DV (use OLS regression becuase "sc_res_humaid" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_humaid media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3c

** sc_res_sancemb H3 (not lagged)
** run a fixed effects OLS regression using "sc_res_sancemb" as the DV (use OLS regression becuase "sc_res_sancemb" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_sancemb media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln 
eststo H3d

** sc_res_total H3 (not lagged)
** run a fixed effects OLS regression using "sc_res_total" as the DV (use OLS regression becuase "sc_res_total" is a continuous variable) and the measurements for H3 and controls as the IVs
xtreg sc_res_total media_mentions_ext year gdppc_ln_ext multiple_mk duration population_ln tradeshare_ln_ext vicrace_white sharedigo_total_ext battledeaths_ln
eststo H3e

** export regression model including each DV
esttab using C:\Users\publicuser\Desktop\RegressionH3NL.doc, star(+ 0.10 * 0.05 ** 0.01 *** 0.001) compress
